﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AzureProvider.SoupMethods.MiniSensor;

namespace AzureProvider.MiniSensor
{
    public class Messages
    {
        string errMessage;
        MessageMethods message_methods = new MessageMethods();
        /// <summary>
        /// Retrieves a channel from the data store.
        /// </summary>
        public Message SelectMessage(Guid id)
        {

            return (Message)message_methods.CreateObject(message_methods.GetEntity(id.ToString(), out errMessage));
        }

        /// <summary>
        /// Inserts a new channel to the data store.
        /// </summary>
        public void InsertMessage(Message message)
        {
            message_methods.Insert(message, out  errMessage);
        }

        /// <summary>
        /// Updates a channel.
        /// </summary>
        public void UpdateChannel(Message message)
        {
            message_methods.Update(message, out  errMessage);
        }

        public List<Message> GetMessages()
        {
            List<Message> messages = message_methods.GetMessages(null, out errMessage).ToList();
            
            return messages;
        }
        public List<Message> GetMessages(Guid ChannelId)
        {
            List<Message> messages = message_methods.GetMessages(ChannelId.ToString(), out errMessage).ToList();

            return messages;
        }
    }
}
